package cmd

import (
	"context"
	_ "gf-assistant/internal/project"
	"gf-assistant/internal/routers"
	_ "gf-assistant/internal/routers"
	_ "gf-assistant/internal/system"
	_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
	_ "github.com/gogf/gf/contrib/nosql/redis/v2"

	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/net/ghttp"
	"github.com/gogf/gf/v2/os/gcmd"
)

var (
	Main = gcmd.Command{
		Name:  "main",
		Usage: "main",
		Brief: "start http server",
		Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
			s := g.Server()
			// health check url
			s.BindHandler("/ping", func(r *ghttp.Request) {
				r.Response.Write("pong")
			})
			s = routers.LoadRoutes(s)

			s.Run()
			return nil
		},
	}
)
